package cn.waterr.luban.demo.cart.main.service.impl;


import cn.water.demo.luban.protocol.cart.dos.CartDO;
import cn.water.demo.luban.protocol.cart.param.CartAddParam;
import cn.water.demo.luban.protocol.cart.param.CartDeleteParam;
import cn.waterr.luban.demo.cart.main.mapper.CartMapper;
import cn.waterr.luban.demo.cart.main.service.CartService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class CartServiceImpl implements CartService {
    
    @Value("${server.port}")
    private String port;
    @Autowired
    private CartMapper cartMapper;

    @Override
    public void cartAdd(CartAddParam param) {

        //DATABASE OBJECT 和表格一一对应
        CartDO cartDO=new CartDO();
        BeanUtils.copyProperties(param,cartDO);
        cartMapper.insertCart(cartDO);
    }

    @Override
    public Boolean deleteCart(CartDeleteParam param) {
        System.out.println("当前处理了删除购物车请求:"+port);
        CartDO cartDO=new CartDO();
        BeanUtils.copyProperties(param,cartDO);
        cartMapper.deleteCart(cartDO);
        return true;
    }
}
